package com.orion.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.orion.domain.Role;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * (Role)表数据库访问层
 *
 * @author makejava
 * @since 2021-08-27 21:21:26
 */
public interface RoleDao extends BaseMapper<Role> {


    /**
     * 根据userId获取角色集合
     *
     * @param userId 用户pk
     * @return 角色集合
     */
    @Select("SELECT * FROM role r LEFT JOIN user_role ur ON r.id = ur.role_id WHERE ur.user_id = #{userId} ")
    List<Role> selectRoleByUserId(@Param("userId") Integer userId);
}
